package com.baidu.shoppingmall.attribute.controller;

import com.baidu.shoppingmall.attribute.domain.AttributeCategoryDTO;
import com.baidu.shoppingmall.attribute.domain.AttributeCategoryVO;
import com.baidu.shoppingmall.attribute.service.AttributeCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


/**
 * @author yp
 */
@RestController
@RequestMapping("/attribute")
public class AttributeCategoryController {

    @Autowired
    private AttributeCategoryService attributeCategoryService;

    @GetMapping("/all")
    public List<AttributeCategoryVO> getCategoryProperties(){
        List<AttributeCategoryDTO> attributeCategoryDtoList=attributeCategoryService.getCategoryProperties();
        List<AttributeCategoryVO> attributeCategoryVoList=new ArrayList<>(attributeCategoryDtoList.size());
        attributeCategoryDtoList.forEach(dto->attributeCategoryVoList.add(dto.clone(AttributeCategoryVO.class)));
        return attributeCategoryVoList;
    }
}
